package com.ftg.learn.chapter03.service;

import com.ftg.learn.chapter03.mapper.UserMapper;
import com.ftg.learn.chapter03.util.SqlSessionUtil;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;


/**
 * @author kangjx
 * @createTime 2022/11/3
 */
@Service
public class UserService {

    //spring 与 mybatis 整合  要息是mybatis容器与spring容器关系
    //mapper 是从mybatis里面取的 mybatis的容器以及sqlsession在spring容器里面
    //google mybatis spring-mybatis.jar [把今天老康 进行优化 以及封装]

    UserMapper userMapper;

    public void test(ApplicationContext applicationContext){
        this.userMapper = SqlSessionUtil.getMapperInnerContainer(UserMapper.class,applicationContext);
        System.out.println(userMapper.showAll());
    }

}
